'''
陈超依 19377189
现代程序设计第四次作业
'''

import networkx as nx

def avg_degree(G : nx.Graph):
    '''输入图，返回平均度'''
    total = 0
    for i in G.degree():
        total += i[1]
    return total/i[0]

def character_spare(LNodes, character):
    '''输入文件名与属性名，返回含该属性的节点列表'''
    result = []
    for n in LNodes:
        info = (n['information'])[:-1]  #去除换行符
        info = info.split(';')
        if character in info:
            result.append(n)
    return result